package hz.mobileproject.pda.broadcast;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Vibrator;


/**
 * Created by hz_qinghua on 2016/11/2.
 */

public class ScanBroadcastReceiver extends BroadcastReceiver  {

    private IShowBarcodeStr iShowView;

    private String barcodeStr;
    private Vibrator mVibrator;


    public ScanBroadcastReceiver(IShowBarcodeStr iShowView) {

        this.iShowView=iShowView;

    }

    @Override
    public void onReceive(Context context, Intent intent) {
        mVibrator = (Vibrator)context.getSystemService(Context.VIBRATOR_SERVICE);

        mVibrator.vibrate(100);

        byte[] barcode = intent.getByteArrayExtra("barocode");
        //byte[] barcode = intent.getByteArrayExtra("barcode");
        int barocodelen = intent.getIntExtra("length", 0);
        byte temp = intent.getByteExtra("barcodeType", (byte) 0);
        barcodeStr = new String(barcode, 0, barocodelen);
        iShowView.updateText(barcodeStr);

    }

    public void setiShowView(IShowBarcodeStr iShowView) {
        this.iShowView = iShowView;
    }





}
